package patrol.mobile.com.mobilepatrol.manager;

import java.util.List;

import io.realm.Realm;
import patrol.mobile.com.mobilepatrol.PatrolApp;
import patrol.mobile.com.mobilepatrol.bean.Org;

/**
 * Created by apple on 17/12/18.
 */

public class OrgManager{

    public static void insert(final String json) {
        del();
        PatrolApp.realm.executeTransactionAsync(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                realm.createAllFromJson(Org.class, json);
            }
        });

    }
    public static void del(){
        PatrolApp.realm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                realm.delete(Org.class);
            }
        });
    }
    public static List<Org> get(){
        return PatrolApp.realm.where(Org.class).findAll();
    }
}
